﻿/// <reference path="_namespace.js" />


/*****************************************************************************
Ajax library class definition. Kevin Robinson 2007.
Class: ajax.windows.FrmSimpleAdmin
/*****************************************************************************/

ajax.lang.addNamespace("ajax.windows");
ajax.lang.imports("ajax.windows.WinFormDisplayFlags");

// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit = function(doc, w, h, taskBar)
{    
    // We largely define how we will look      
    ajax.windows.FrmSimpleAdminEdit.superConstructor.call(this, doc, "", w, h, ajax.windows.WinFormDisplayFlags, "Simple Admin Edit", taskBar, false, taskBar);
    this.set_isTemplateControl(true); // Use template
    this.dataSource         = null; // Datasource we bind to
    
    // public events
    this.getEvent(this.window, "onSave");    
    
}
// --------------------------------------------------------------------
ajax.lang.extend("ajax.windows.FrmSimpleAdminEdit", "ajax.windows.WinForm");
// --------------------------------------------------------------------

ajax.windows.FrmSimpleAdminEdit.prototype.add_save = function(handler) { this.getEvent(this.getWindow(), "onSave").addListener(handler); };
ajax.windows.FrmSimpleAdminEdit.prototype.remove_save = function(handler) { this.getEvent(this.getWindow(), "onSave").removeListener(handler);  };

// CLIENTS SHOULD OVERRIDE THESE to provide their own functionality
// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.prototype.dataBind = function()
{ // Override this please  
    // Copy data from this.dataSource *TO* GUI elements  
}

// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.prototype.save = function()
{ // override this please.
    // Create new row for this.dataSource with values *FROM* GUI elements
    this.onSave.call(this, this.dataSource);
}

// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.prototype.onTxtKeyUp = function(e)
{
    if (this.keyboard.getKeyCode(e) == this.keyboard.getKeys().KeyReturn)
        this.save();
}

// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.prototype.close = function()
{
    this.hide();
}

// --------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.prototype.toString = function()
{
    return "ajax.windows.FrmSimpleAdminEdit";
}

//-----------------------------------------------------------------------------
ajax.windows.FrmSimpleAdminEdit.cast = function(obj)
{///<returns type="ajax.windows.FrmSimpleAdminEdit"/>
    return obj;
}